#include <iostream>

class Operand;

class OpTreeNode
{
public:
	OpTreeNode(){}

	OpTreeNode(Operand* current, OpTreeNode* left, OpTreeNode* right);

	OpTreeNode(Operand* current, OpTreeNode* left, Operand* rightOp);
	
	OpTreeNode(Operand* current, Operand* leftOp, OpTreeNode* right);
	
	OpTreeNode(Operand* current, Operand* leftOp, Operand* rightOp);
		

	~OpTreeNode(){}

	void SetValue(int value) { current->SetValue(value); }

	int GetValue() { return this->Execute(); }

	Operand* GetCurrent() { return this->current; }

	int Execute();

	void Print();

private:
	Operand* current;
	OpTreeNode* left;
	OpTreeNode* right;
};

class Condition
{
public:
	Condition(){}
	Condition(OpTreeNode* src)
	{
		this->src = src;
	}
	Condition(Operand* srcOp)
	{
		this->src = new OpTreeNode(srcOp, (OpTreeNode*) NULL, (OpTreeNode*) NULL);
	}

	bool GetState()
	{
		if ( src == NULL ) return true;
		if ( src->Execute() == 0 ) return false;
		else return true;
	}

	OpTreeNode* GetSrc() { return this->src; }

	~Condition(){}
private:
	OpTreeNode* src;
};
